package com.bus.admin;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;


/**
 * spring-boot-plus 项目启动入口
 * @author geekidea
 * @since 2018-11-08
 */
@MapperScan({"com.bus.admin.mapper"})
//扫描公共模块下的包     注入注解
@ComponentScan(basePackages = {"com.bus.admin"})
@ServletComponentScan(value = "com.bus.admin.config")
@SpringBootApplication
@EnableCaching
@Slf4j
@EnableScheduling  //定时任务
@EnableAsync
public class Application {
    //springboot2.0开启websocket支持
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        log.info("正在启动开启websocket支持") ;
        return new ServerEndpointExporter();
    }


    public static void main(String[] args) {
        log.info("{}正在启动",Application.class);
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        //解决websocket无法注入bean
      //  WebScoketService.setApplicationContext(context);
        log.info("{}启动成功",Application.class  );


    }

}
